//
//  MYGChatFunctionCell.swift
//  MYGrow
//
//  Created by 小火科技 on 2024/3/1.
//

import UIKit
import QMUIKit

enum MYGChatFunctionType {
    case image
    case photo
    case position
    case message
    case report
    case appoint
    
    var image: String {
        switch self {
        case .image:
            return "image"
        case .photo:
            return "photo"
        case .position:
            return "position"
        case .message:
            return "message"
        case .report:
            return "report"
        case .appoint:
            return "appoint"
        }
    }
    
    var name: String {
        switch self {
        case .image:
            return "照片"
        case .photo:
            return "拍摄"
        case .position:
            return "位置"
        case .message:
            return "消息模板"
        case .report:
            return "分享报告"
        case .appoint:
            return "信息申请"
        }
    }
}

class MYGChatFunctionCell: UICollectionViewCell {
    // MARK: - Property
    var type: MYGChatFunctionType {
        get {
            .appoint
        }
        set {
            button.setTitle(newValue.name, for: .normal)
            button.setImage(UIImage(named: "Chat/Function/\(newValue.image)"), for: .normal)
        }
    }
    
    // MARK: - init
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - UI
    private func configUI() {
        contentView.addSubview(button)
        
        button.snp.makeConstraints { make in
            make.center.equalToSuperview()
        }
    }
    // MARK: - lazy load
    private lazy var button: QMUIButton = {
        let btn = QMUIButton()
        btn.imagePosition = .top
        btn.spacingBetweenImageAndTitle = 10
        btn.titleLabel?.font = .regular(13)
        btn.setTitleColor(.rgba(38, 38, 40, 1), for: .normal)
        btn.isUserInteractionEnabled = false
        return btn
    }()
}
